// by Xeno
private ["_vehicle"];
#include "x_setup.sqf"
#include "x_macros.sqf"

#define __Poss _poss = x_sm_pos select 0;
#define __PossAndOther _poss = x_sm_pos select 0;_pos_other = x_sm_pos select 1;

x_sm_pos = [[4726.85,15689,0],[4385.75,15825.4,0],[4415.64,15790.9,0],[4375.74,15790.8,0],[4392.87,15521.3,0],[4532.88,15304.8,0],[4585.08,15287.2,0],[4978.4,15466.1,0],[4855.92,15535.1,0],[4930.69,15514.1,0],[4956.34,15760.8,0],[4949.85,15827.9,0],[4964.33,16067,0],[4987.25,15717.1,0],[4395.8,15350.6,0],   [4574.74,15374.2,0],[4368.82,15737,0],[5044.83,15799.3,0],[4860.15,15679.2,0]]; // index: 25,   enemy officer on Isla del Vasal or Isla del Vida
x_sm_type = "normal"; // "convoy"

#ifdef __SMMISSIONS_MARKER__
if (true) exitWith {};
#endif

if (X_Client) then {
	d_current_mission_text = "A high enemy officer hides on Isla del Vasal or Isla del Vida. He was the one who started the attack agains south Sahrani. Eliminate him !";
	d_current_mission_resolved_text = "The enemy officer is dead. Good job.";
};

if (isServer) then {
	_officer = switch (d_enemy_side) do {
		case "EAST": {"RU_Commander"};
		case "WEST": {"USMC_Soldier_Officer"};
		case "GUER": {"GUE_Commander"};
	};
	_ranside = floor random 14;
	_poss = x_sm_pos select (_ranside + 1);
	__GetEGrp(_newgroup)
	_sm_vehicle = _newgroup createUnit [_officer, _poss, [], 0, "FORM"];
	[_sm_vehicle] join _newgroup;
	allunits_add set [count allunits_add, _sm_vehicle];
	#ifndef __TT__
	_sm_vehicle addEventHandler ["killed", {_this call XKilledSMTargetNormal}];
	#endif
	#ifdef __TT__
	_sm_vehicle addEventHandler ["killed", {_this call XKilledSMTargetTT}];
	#endif
	sleep 2.123;
	_leader = leader _newgroup;
	_leader setRank "COLONEL";
	_newgroup allowFleeing 0;
	_newgroup setbehaviour "AWARE";
	_leader disableAI "MOVE";
	sleep 2.123;
	["specops", 2, "basic", 1, _poss,80,true] spawn XCreateInf;
	sleep 2.111;
	_pos_other = x_sm_pos select 15;
	["shilka", 1, "bmp", 1, "tank", 0, _pos_other,1,130,true] spawn XCreateArmor;
	sleep 2.123;
	["specops", 1, "basic", 0, _pos_other,80,true] spawn XCreateInf;
	sleep 2.123;
	_pos_other = x_sm_pos select 16;
	["shilka", 1, "bmp", 1, "tank", 0, _pos_other,1,130,true] spawn XCreateArmor;
	sleep 2.123;
	["specops", 1, "basic", 0, _pos_other,0] spawn XCreateInf;
	sleep 2.123;
	_pos_other = x_sm_pos select 17;
	["shilka", 1, "bmp", 1, "tank", 0, _pos_other,1,130,true] spawn XCreateArmor;
	sleep 2.123;
	["specops", 1, "basic", 0, _pos_other,80,true] spawn XCreateInf;
	sleep 2.123;
	_pos_other = x_sm_pos select 18;
	["shilka", 1, "bmp", 1, "tank", 0, _pos_other,1,130,true] spawn XCreateArmor;
	sleep 2.123;
	["specops", 1, "basic", 0, _pos_other,80,true] spawn XCreateInf;
	sleep 2.123;
};

if (true) exitWith {};